$(function(){
	var qrcode = new QRCode(document.getElementById("qrcode"), {
		text : "http://www.yu9fang.com/reg.html?code=" + promoCode,
		width : 300,
		height : 300
	});
	
	$(".order-view-tap ul li").click(function(){
		$(".order-view-tap ul li").removeClass("activy");
		$(this).addClass("activy");
		// 隐藏、显示
		$(".order-view-wapper").hide();
		var code = $(this).attr("code");
		$("#" + code + "Div").show();
		switch(code) {
			case "member":
				getMember();
				break;
			case "score":
				getScore();
				break;
		}
	});
});
/**
 * 获取推广人数
 */
function getMember() {
	$.ajax({type:"POST", url: "/user/members.html",
		dataType: "json", 
		success: function(data) {
			var html = [];
			if(data && data.length > 0) {
				for(var i in data) {
					html.push('<li class="order-view-detail clear">');
					html.push('<div class="score-list-item score-list-user">'+data[i].username+'</div>');
					html.push('<div class="score-list-item score-list-date">'+data[i].createTime.substring(0, data[i].createTime.indexOf(" "))+'</div>');
					html.push('</li>');
				}
			} else {
				html.push('<li><span class="icon-order-no"></span>');
				html.push('<p>暂无数据</p></li>');
			}
			$("#memberDiv ul li").append(html.join(""));
		}
	});
}


/**
 * 获取推广分数
 */
function getScore() {
	$.ajax({type:"POST", url: "/score/myScore.html?code=2",
		dataType: "json", 
		success: function(data) {
			var html = [];
			if(data && data.length > 0) {
				for(var i in data) {
					html.push('<li class="order-view-detail clear">');
					html.push('<div class="score-list-item score-list-date">'+data[i].createTime.substring(0, data[i].createTime.indexOf(" "))+'</div>');
					html.push('<div class="score-list-item score-list-change">'+data[i].change+data[i].scoreChange+'</div>');
					html.push('<div class="score-list-item score-list-resion">'+data[i].changeReasonDesc+'</div>');
					html.push('</li>');
				}
			} else {
				html.push('<li><span class="icon-order-no"></span>');
				html.push('<p>暂无数据</p></li>');
			}
			$("#scoreDiv ul li").append(html.join(""));
		}
	});
}
